//
//  CollectionViewOneCell.m
//  lx
//
//  Created by 李响 on 15/6/9.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "CollectionViewOneCell.h"
#import "Table.h"
#import "UIImageView+WebCache.h"
@implementation CollectionViewOneCell
- (void)dealloc
{
    [_main release];
    [_threeImageView release];
    [_threeLable release];
    [_playImageView release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.threeLable = [[UILabel alloc] init];
        [self.contentView addSubview:self.threeLable];
        [_threeLable release];
        
        self.threeImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.threeImageView];
        [_threeImageView release];
        
        self.playImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.playImageView];
        [_playImageView release];
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    CGFloat width = self.contentView.frame.size.width;
    CGFloat height = self.contentView.frame.size.height;
    self.threeImageView.frame = CGRectMake(0, 0, width * 9 / 10, height * 9 / 10);
    self.threeLable.frame = CGRectMake(0, height * 9 / 10, width, height / 2);
    self.playImageView.frame = CGRectMake(width / 9, height / 10, width * 7 / 10, height * 7 / 10);
    
}
- (void)setMain:(Table *)main
{
    if (_main != main) {
        [_main release];
        _main = [main retain];
    }
    [self.threeImageView sd_setImageWithURL:[NSURL URLWithString:_main.pic]];
    self.threeLable.text = _main.rname;
    self.threeLable.font = [UIFont systemFontOfSize:13];
    //适应行数
    self.threeLable.numberOfLines = 0;
    self.playImageView.image = [UIImage imageNamed:@"bofang.png"];
}

@end
